'''
https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-ii/description/
'''

from typing import List


class Solution:

    # 能卖就卖
    def maxProfit(self, prices: List[int]) -> int:
        min_price = prices[0]
        total_profit = 0
        for price in prices:
            if price >= min_price:
                total_profit += price - min_price
                min_price = price
            else:
                min_price = price
        return total_profit
